package org.puremvc.as3.multicore.utilities.assetLoader.clients.fzip
{
	import deng.fzip.FZip;
	import deng.fzip.FZipEvent;
	
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	
	import org.puremvc.as3.multicore.utilities.assetLoader.clients.LoaderClientBase;
	import org.puremvc.as3.multicore.utilities.assetLoader.interfaces.ILoaderClientInfo;

	public class FzipClient extends LoaderClientBase
	{
		private var mFZip:FZip;
		
		public function FzipClient(cli:ILoaderClientInfo)
		{
			//TODO: implement function
			super(cli);
		}
		
		override protected function initialiseLoad():void
		{
			mFZip = new FZip();
		}
		
		override protected function startLoad():void
		{
			mFZip.load(loaderClientInfo.urlRequest)
		}
		
		override protected function prepareAsset(event:Event):void
		{
			loaderClientInfo.setAsset(mFZip)
		}
		
		override protected function addListeners():void
		{
			mFZip.addEventListener(Event.COMPLETE, loadCompleteHandler);
			mFZip.addEventListener(FZipEvent.FILE_LOADED, relayHandler);
			mFZip.addEventListener(HTTPStatusEvent.HTTP_STATUS, relayHandler);
			mFZip.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			mFZip.addEventListener(ProgressEvent.PROGRESS, relayHandler);
		}
		
		override protected function removeListeners():void{

			mFZip.removeEventListener(Event.COMPLETE, loadCompleteHandler);
			mFZip.removeEventListener(FZipEvent.FILE_LOADED, relayHandler);
			mFZip.removeEventListener(HTTPStatusEvent.HTTP_STATUS, relayHandler);
			mFZip.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
			mFZip.removeEventListener(ProgressEvent.PROGRESS, relayHandler);
		}
		
	}
}